package com.szy.douyou_gateway.client;

import com.szy.douyou_article.dao.Article;
import com.szy.douyou_article.dao.State;
import com.szy.douyou_article.dao.req.ArticleReq;
import com.szy.douyou_gateway.config.ResultDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @author sunziyan
 * @date 2022/4/21
 */

@Component
@FeignClient("nacos-douyou-article")
public interface ArticleClient {

    /**
     * 调用接口分页查询帖子
     *
     * @param articleReq
     * @return
     */
    @PostMapping("/article/queryPage")
    ResultDTO queryPage(@RequestBody ArticleReq articleReq);

    /**
     * 调用接口查询一篇帖子
     *
     * @param articleId
     * @return
     */
    @GetMapping("/article/queryOne/{articleId}")
    ResultDTO<Article> queryOne(@PathVariable("articleId") Long articleId);

    /**
     * 调用接口修改一篇帖子
     * @param article
     * @return
     */
    @PostMapping("/article/updateOne")
    ResultDTO updateOne(@RequestBody Article article);

    /**
     * 调用接口新增一篇帖子
     * @param article
     * @return
     */
    @PostMapping("/article/addOne")
    ResultDTO addOne(@RequestBody Article article);


    /**
     * 调用接口删除一篇帖子
     *
     * @param articleId
     * @return
     */
    @GetMapping("/article/deleteOne/{articleId}")
    ResultDTO deleteOne(@PathVariable("articleId") Long articleId);

    /**
     * 调用接口帖子浏览量加一
     *
     * @param articleId
     * @return
     */
    @GetMapping("/article/addArticleViews/{articleId}")
    ResultDTO addArticleViews(@PathVariable("articleId") Long articleId);

    /**
     * 调用接口获取帖子全部好评差评
     * @param articleId
     * @return
     */
    @GetMapping("/article/getAllState/{articleId}")
    ResultDTO getAllState(@PathVariable("articleId")Long articleId);


    /**
     * 调用接口获取用户在该帖子的评价状态
     * @param articleId
     * @param userId
     * @return
     */
    @GetMapping("/article/getMyState/{articleId}/{userId}")
    ResultDTO getMyState(@PathVariable("articleId") Long articleId, @PathVariable("userId") Long userId);

    /**
     * 调用接口创建用户在帖子中的评价状态
     * @param state
     * @return
     */
    @PostMapping("/article/createState")
    ResultDTO createState(@RequestBody State state);

    /**
     * 调用接口改变用户在帖子中的评价状态
     * @param state
     * @return
     */
    @PostMapping("/article/changeState")
    ResultDTO changeState(@RequestBody State state);


}
